#include "UnitTest++.h"
#include "CrcCalculator.h"
#include "ZipReader.h"

TEST(GivenAFileShouldCalculateTheCRCOfTheBuffer)
{
    ZipReader reader("resources/file.zip");
    FileHeader* fileHeader = reader.extractFileHeaderFields(0); 
    
    unsigned long expectedCrc = fileHeader->crc_;
    unsigned long actualCrc = calculateCRC32(fileHeader->fileData_,fileHeader->unCompressedSize_);
    
    CHECK(actualCrc == expectedCrc);
    
    delete fileHeader;
}

TEST(GivenAFileHeaderShouldCalculateTheCRCOfTheBufferAndBeTheSameOfTheFileHeader)
{
    ZipReader reader("resources/file.zip");
    FileHeader* fileHeader = reader.extractFileHeaderFields(0); 
    
    unsigned long expectedCrc = fileHeader->crc_;
    unsigned long actualCrc = fileHeader->calculateCRC();
    
    CHECK(actualCrc == expectedCrc);
    
    delete fileHeader;
}